#!/usr/bin/perl -w

my $file = shift;
@contigs=`ls split*`;

chomp @contigs;

foreach my $contig(@contigs){ system("bsub -J aphid_peach_exonerate_ds_$contig -o $contig.exonerate -N -R \"rusage[mem=5000] span[ptile=4]\" -n 4 \'exonerate-2.2.0 exonerate --model est2genome --showtargetgff --showvulgar yes --softmaskquery yes --softmasktarget yes --bestn 20  --minintron 20 --maxintron 50000 --score 100 --percent 50 --geneseed 100 --ryo \">%qi\\tlength=%ql\\talnlen=%qal\\tscore=%s\\tpercentage=%pi\\nTarget>%ti\\tlength=%tl\\talnlen=%tal\\n --showalignment\" no --query $contig --target aphids-mpi-k61-contigs_modified_over5000.fa.masked\'"); }

system("bsub -w \'done(aphid_peach_exonerate_ds_*)\' -J aphid_peach_combine -N \'cat split*exonerate > $file-all.exonerate\'");

system("bsub -w \'done(aphid_peach_combine)\' -J aphid_peach_convert -N \'exonerate2gff.pl $file-all.exonerate > $file\'");

